package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndAtmAttachment;
import com.bestow.basic.service.IFndAtmAttachmentService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 附件信息Controller
 * 
 * @author liliu
 * @date 2022-09-22
 */
@RestController
@RequestMapping("/basic/atmAttachment")
public class FndAtmAttachmentController extends BaseController
{
    @Autowired
    private IFndAtmAttachmentService fndAtmAttachmentService;

    /**
     * 查询附件信息列表
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachment:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndAtmAttachment fndAtmAttachment)
    {
        startPage();
        List<FndAtmAttachment> list = fndAtmAttachmentService.selectFndAtmAttachmentList(fndAtmAttachment);
        return getDataTable(list);
    }

    /**
     * 导出附件信息列表
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachment:export')")
    @Log(title = "附件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndAtmAttachment fndAtmAttachment)
    {
        List<FndAtmAttachment> list = fndAtmAttachmentService.selectFndAtmAttachmentList(fndAtmAttachment);
        ExcelUtil<FndAtmAttachment> util = new ExcelUtil<FndAtmAttachment>(FndAtmAttachment.class);
        util.exportExcel(response, list, "附件信息数据");
    }

    /**
     * 获取附件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachment:query')")
    @GetMapping(value = "/{attachmentId}")
    public AjaxResult getInfo(@PathVariable("attachmentId") Long attachmentId)
    {
        return AjaxResult.success(fndAtmAttachmentService.selectFndAtmAttachmentByAttachmentId(attachmentId));
    }

    /**
     * 新增附件信息
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachment:add')")
    @Log(title = "附件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndAtmAttachment fndAtmAttachment)
    {
        return toAjax(fndAtmAttachmentService.insertFndAtmAttachment(fndAtmAttachment));
    }

    /**
     * 修改附件信息
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachment:edit')")
    @Log(title = "附件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndAtmAttachment fndAtmAttachment)
    {
        return toAjax(fndAtmAttachmentService.updateFndAtmAttachment(fndAtmAttachment));
    }

    /**
     * 删除附件信息
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachment:remove')")
    @Log(title = "附件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{attachmentIds}")
    public AjaxResult remove(@PathVariable Long[] attachmentIds)
    {
        return toAjax(fndAtmAttachmentService.deleteFndAtmAttachmentByAttachmentIds(attachmentIds));
    }
}
